home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.006 / xemacs-1 / lib / xemacs-19.13 / info / xemacs.info-6 < prev    next >
Encoding:
GNU Info File  |  1995-09-01  |  49.4 KB  |  1,139 lines

  1. This is Info file ../../info/xemacs.info, produced by Makeinfo-1.63
  2. from the input file xemacs.texi.
  3.  
  4.    This file documents the XEmacs editor.
  5.  
  6.    Copyright (C) 1985, 1986, 1988 Richard M. Stallman.  Copyright (C)
  7. 1991, 1992, 1993, 1994 Lucid, Inc.  Copyright (C) 1993, 1994 Sun
  8. Microsystems, Inc.  Copyright (C) 1995 Amdahl Corporation.
  9.  
  10.    Permission is granted to make and distribute verbatim copies of this
  11. manual provided the copyright notice and this permission notice are
  12. preserved on all copies.
  13.  
  14.    Permission is granted to copy and distribute modified versions of
  15. this manual under the conditions for verbatim copying, provided also
  16. that the sections entitled "The GNU Manifesto", "Distribution" and "GNU
  17. General Public License" are included exactly as in the original, and
  18. provided that the entire resulting derived work is distributed under the
  19. terms of a permission notice identical to this one.
  20.  
  21.    Permission is granted to copy and distribute translations of this
  22. manual into another language, under the above conditions for modified
  23. versions, except that the sections entitled "The GNU Manifesto",
  24. "Distribution" and "GNU General Public License" may be included in a
  25. translation approved by the author instead of in the original English.
  26.  
  27. 
  28. File: xemacs.info,  Node: Search Case,  Next: Replace,  Prev: Regexps,  Up: Search
  29.  
  30. Searching and Case
  31. ==================
  32.  
  33.    All searches in Emacs normally ignore the case of the text they are
  34. searching through; if you specify searching for `FOO', `Foo' and `foo'
  35. are also considered a match.  Regexps, and in particular character
  36. sets, are included: `[aB]' matches `a' or `A' or `b' or `B'.
  37.  
  38.    If you want a case-sensitive search, set the variable
  39. `case-fold-search' to `nil'.  Then all letters must match exactly,
  40. including case. `case-fold-search' is a per-buffer variable; altering
  41. it affects only the current buffer, but there is a default value which
  42. you can change as well.  *Note Locals::.  You can also use Case
  43. Sensitive Search from the Options menu on your screen.
  44.  
  45. 
  46. File: xemacs.info,  Node: Replace,  Next: Other Repeating Search,  Prev: Search Case,  Up: Search
  47.  
  48. Replacement Commands
  49. ====================
  50.  
  51.    Global search-and-replace operations are not needed as often in
  52. Emacs as they are in other editors, but they are available.  In
  53. addition to the simple `replace-string' command which is like that
  54. found in most editors, there is a `query-replace' command which asks
  55. you, for each occurrence of a pattern, whether to replace it.
  56.  
  57.    The replace commands all replace one string (or regexp) with one
  58. replacement string.  It is possible to perform several replacements in
  59. parallel using the command `expand-region-abbrevs'.  *Note Expanding
  60. Abbrevs::.
  61.  
  62. * Menu:
  63.  
  64. * Unconditional Replace::  Replacing all matches for a string.
  65. * Regexp Replace::         Replacing all matches for a regexp.
  66. * Replacement and Case::   How replacements preserve case of letters.
  67. * Query Replace::          How to use querying.
  68.  
  69. 
  70. File: xemacs.info,  Node: Unconditional Replace,  Next: Regexp Replace,  Prev: Replace,  Up: Replace
  71.  
  72. Unconditional Replacement
  73. -------------------------
  74.  
  75. `M-x replace-string RET STRING RET NEWSTRING RET'
  76.      Replace every occurrence of STRING with NEWSTRING.
  77.  
  78. `M-x replace-regexp RET REGEXP RET NEWSTRING RET'
  79.      Replace every match for REGEXP with NEWSTRING.
  80.  
  81.    To replace every instance of `foo' after point with `bar', use the
  82. command `M-x replace-string' with the two arguments `foo' and `bar'.
  83. Replacement occurs only after point: if you want to cover the whole
  84. buffer you must go to the beginning first.  By default, all occurrences
  85. up to the end of the buffer are replaced.  To limit replacement to part
  86. of the buffer, narrow to that part of the buffer before doing the
  87. replacement (*note Narrowing::.).
  88.  
  89.    When `replace-string' exits, point is left at the last occurrence
  90. replaced.  The value of point when the `replace-string' command was
  91. issued is remembered on the mark ring; `C-u C-SPC' moves back there.
  92.  
  93.    A numeric argument restricts replacement to matches that are
  94. surrounded by word boundaries.
  95.  
  96. 
  97. File: xemacs.info,  Node: Regexp Replace,  Next: Replacement and Case,  Prev: Unconditional Replace,  Up: Replace
  98.  
  99. Regexp Replacement
  100. ------------------
  101.  
  102.    `replace-string' replaces exact matches for a single string.  The
  103. similar command `replace-regexp' replaces any match for a specified
  104. pattern.
  105.  
  106.    In `replace-regexp', the NEWSTRING need not be constant.  It can
  107. refer to all or part of what is matched by the REGEXP.  `\&' in
  108. NEWSTRING stands for the entire text being replaced.  `\D' in
  109. NEWSTRING, where D is a digit, stands for whatever matched the D'th
  110. parenthesized grouping in REGEXP.  For example,
  111.  
  112.      M-x replace-regexp RET c[ad]+r RET \&-safe RET
  113.  
  114. would replace (for example) `cadr' with `cadr-safe' and `cddr' with
  115. `cddr-safe'.
  116.  
  117.      M-x replace-regexp RET \(c[ad]+r\)-safe RET \1 RET
  118.  
  119. would perform exactly the opposite replacements.  To include a `\' in
  120. the text to replace with, you must give `\\'.
  121.  
  122. 
  123. File: xemacs.info,  Node: Replacement and Case,  Next: Query Replace,  Prev: Regexp Replace,  Up: Replace
  124.  
  125. Replace Commands and Case
  126. -------------------------
  127.  
  128.    If the arguments to a replace command are in lower case, the command
  129. preserves case when it makes a replacement.  Thus, the following
  130. command:
  131.  
  132.      M-x replace-string RET foo RET bar RET
  133.  
  134. replaces a lower-case `foo' with a lower case `bar', `FOO' with `BAR',
  135. and `Foo' with `Bar'.  If upper-case letters are used in the second
  136. argument, they remain upper-case every time that argument is inserted.
  137. If upper-case letters are used in the first argument, the second
  138. argument is always substituted exactly as given, with no case
  139. conversion.  Likewise, if the variable `case-replace' is set to `nil',
  140. replacement is done without case conversion.  If `case-fold-search' is
  141. set to `nil', case is significant in matching occurrences of `foo' to
  142. replace; also, case conversion of the replacement string is not done.
  143.  
  144. 
  145. File: xemacs.info,  Node: Query Replace,  Prev: Replacement and Case,  Up: Replace
  146.  
  147. Query Replace
  148. -------------
  149.  
  150. `M-% STRING RET NEWSTRING RET'
  151. `M-x query-replace RET STRING RET NEWSTRING RET'
  152.      Replace some occurrences of STRING with NEWSTRING.
  153.  
  154. `M-x query-replace-regexp RET REGEXP RET NEWSTRING RET'
  155.      Replace some matches for REGEXP with NEWSTRING.
  156.  
  157.    If you want to change only some of the occurrences of `foo' to
  158. `bar', not all of them, you can use `query-replace' instead of `M-%'.
  159. This command finds occurrences of `foo' one by one, displays each
  160. occurrence, and asks you whether to replace it.  A numeric argument to
  161. `query-replace' tells it to consider only occurrences that are bounded
  162. by word-delimiter characters.
  163.  
  164.    Aside from querying, `query-replace' works just like
  165. `replace-string', and `query-replace-regexp' works just like
  166. `replace-regexp'.
  167.  
  168.    The things you can type when you are shown an occurrence of STRING
  169. or a match for REGEXP are:
  170.  
  171. `SPC'
  172.      to replace the occurrence with NEWSTRING.  This preserves case,
  173.      just like `replace-string', provided `case-replace' is non-`nil',
  174.      as it normally is.
  175.  
  176. `DEL'
  177.      to skip to the next occurrence without replacing this one.
  178.  
  179. `, (Comma)'
  180.      to replace this occurrence and display the result.  You are then
  181.      prompted for another input character.  However, since the
  182.      replacement has already been made, DEL and SPC are equivalent.  At
  183.      this point, you can type `C-r' (see below) to alter the replaced
  184.      text.  To undo the replacement, you can type `C-x u'.  This exits
  185.      the `query-replace'.  If you want to do further replacement you
  186.      must use `C-x ESC' to restart (*note Repetition::.).
  187.  
  188. `ESC'
  189.      to exit without doing any more replacements.
  190.  
  191. `. (Period)'
  192.      to replace this occurrence and then exit.
  193.  
  194. `!'
  195.      to replace all remaining occurrences without asking again.
  196.  
  197. `^'
  198.      to go back to the location of the previous occurrence (or what
  199.      used to be an occurrence), in case you changed it by mistake.
  200.      This works by popping the mark ring.  Only one `^' in a row is
  201.      allowed, because only one previous replacement location is kept
  202.      during `query-replace'.
  203.  
  204. `C-r'
  205.      to enter a recursive editing level, in case the occurrence needs
  206.      to be edited rather than just replaced with NEWSTRING.  When you
  207.      are done, exit the recursive editing level with `C-M-c' and the
  208.      next occurrence will be displayed.  *Note Recursive Edit::.
  209.  
  210. `C-w'
  211.      to delete the occurrence, and then enter a recursive editing level
  212.      as in `C-r'.  Use the recursive edit to insert text to replace the
  213.      deleted occurrence of STRING.  When done, exit the recursive
  214.      editing level with `C-M-c' and the next occurrence will be
  215.      displayed.
  216.  
  217. `C-l'
  218.      to redisplay the screen and then give another answer.
  219.  
  220. `C-h'
  221.      to display a message summarizing these options, then give another
  222.      answer.
  223.  
  224.    If you type any other character, Emacs exits the `query-replace', and
  225. executes the character as a command.  To restart the `query-replace',
  226. use `C-x ESC', which repeats the `query-replace' because it used the
  227. minibuffer to read its arguments.  *Note C-x ESC: Repetition.
  228.  
  229. 
  230. File: xemacs.info,  Node: Other Repeating Search,  Prev: Replace,  Up: Search
  231.  
  232. Other Search-and-Loop Commands
  233. ==============================
  234.  
  235.    Here are some other commands that find matches for a regular
  236. expression.  They all operate from point to the end of the buffer.
  237.  
  238. `M-x occur'
  239.      Print each line that follows point and contains a match for the
  240.      specified regexp.  A numeric argument specifies the number of
  241.      context lines to print before and after each matching line; the
  242.      default is none.
  243.  
  244.      The buffer `*Occur*' containing the output serves as a menu for
  245.      finding occurrences in their original context.  Find an occurrence
  246.      as listed in `*Occur*', position point there, and type `C-c C-c';
  247.      this switches to the buffer that was searched and moves point to
  248.      the original of the same occurrence.
  249.  
  250. `M-x list-matching-lines'
  251.      Synonym for `M-x occur'.
  252.  
  253. `M-x count-matches'
  254.      Print the number of matches following point for the specified
  255.      regexp.
  256.  
  257. `M-x delete-non-matching-lines'
  258.      Delete each line that follows point and does not contain a match
  259.      for the specified regexp.
  260.  
  261. `M-x delete-matching-lines'
  262.      Delete each line that follows point and contains a match for the
  263.      specified regexp.
  264.  
  265. 
  266. File: xemacs.info,  Node: Fixit,  Next: Files,  Prev: Search,  Up: Top
  267.  
  268. Commands for Fixing Typos
  269. *************************
  270.  
  271.    This chapter describes commands that are especially useful when you
  272. catch a mistake in your text just after you have made it, or when you
  273. change your mind while composing text on line.
  274.  
  275. * Menu:
  276.  
  277. * Kill Errors:: Commands to kill a batch of recently entered text.
  278. * Transpose::   Exchanging two characters, words, lines, lists...
  279. * Fixing Case:: Correcting case of last word entered.
  280. * Spelling::    Apply spelling checker to a word, or a whole file.
  281.  
  282. 
  283. File: xemacs.info,  Node: Kill Errors,  Next: Transpose,  Prev: Fixit,  Up: Fixit
  284.  
  285. Killing Your Mistakes
  286. =====================
  287.  
  288. `DEL'
  289.      Delete last character (`delete-backward-char').
  290.  
  291. `M-DEL'
  292.      Kill last word (`backward-kill-word').
  293.  
  294. `C-x DEL'
  295.      Kill to beginning of sentence (`backward-kill-sentence').
  296.  
  297.    The DEL character (`delete-backward-char') is the most important
  298. correction command.  When used among graphic (self-inserting)
  299. characters, it can be thought of as canceling the last character typed.
  300.  
  301.    When your mistake is longer than a couple of characters, it might be
  302. more convenient to use `M-DEL' or `C-x DEL'.  `M-DEL' kills back to the
  303. start of the last word, and `C-x DEL' kills back to the start of the
  304. last sentence.  `C-x DEL' is particularly useful when you are thinking
  305. of what to write as you type it, in case you change your mind about
  306. phrasing.  `M-DEL' and `C-x DEL' save the killed text for `C-y' and
  307. `M-y' to retrieve.  *Note Yanking::.
  308.  
  309.    `M-DEL' is often useful even when you have typed only a few
  310. characters wrong, if you know you are confused in your typing and aren't
  311. sure exactly what you typed.  At such a time, you cannot correct with
  312. DEL except by looking at the screen to see what you did.  It requires
  313. less thought to kill the whole word and start over.
  314.  
  315. 
  316. File: xemacs.info,  Node: Transpose,  Next: Fixing Case,  Prev: Kill Errors,  Up: Fixit
  317.  
  318. Transposing Text
  319. ================
  320.  
  321. `C-t'
  322.      Transpose two characters (`transpose-chars').
  323.  
  324. `M-t'
  325.      Transpose two words (`transpose-words').
  326.  
  327. `C-M-t'
  328.      Transpose two balanced expressions (`transpose-sexps').
  329.  
  330. `C-x C-t'
  331.      Transpose two lines (`transpose-lines').
  332.  
  333.    The common error of transposing two adjacent characters can be fixed
  334. with the `C-t' command (`transpose-chars').  Normally, `C-t' transposes
  335. the two characters on either side of point.  When given at the end of a
  336. line, `C-t' transposes the last two characters on the line, rather than
  337. transposing the last character of the line with the newline, which
  338. would be useless.  If you catch a transposition error right away, you
  339. can fix it with just `C-t'.  If you catch the error later,  move the
  340. cursor back to between the two transposed characters.  If you
  341. transposed a space with the last character of the word before it, the
  342. word motion commands are a good way of getting there.  Otherwise, a
  343. reverse search (`C-r') is often the best way.  *Note Search::.
  344.  
  345.    `Meta-t' (`transpose-words') transposes the word before point with
  346. the word after point.  It moves point forward over a word, dragging the
  347. word preceding or containing point forward as well.  The punctuation
  348. characters between the words do not move.  For example, `FOO, BAR'
  349. transposes into `BAR, FOO' rather than `BAR FOO,'.
  350.  
  351.    `C-M-t' (`transpose-sexps') is a similar command for transposing two
  352. expressions (*note Lists::.), and `C-x C-t' (`transpose-lines')
  353. exchanges lines.  It works like `M-t' but in determines the division of
  354. the text into syntactic units differently.
  355.  
  356.    A numeric argument to a transpose command serves as a repeat count:
  357. it tells the transpose command to move the character (word, sexp, line)
  358. before or containing point across several other characters (words,
  359. sexps, lines).  For example, `C-u 3 C-t' moves the character before
  360. point forward across three other characters.  This is equivalent to
  361. repeating `C-t' three times.  `C-u - 4 M-t' moves the word before point
  362. backward across four words.  `C-u - C-M-t' would cancel the effect of
  363. plain `C-M-t'.
  364.  
  365.    A numeric argument of zero transposes the character (word, sexp,
  366. line) ending after point with the one ending after the mark (otherwise a
  367. command with a repeat count of zero would do nothing).
  368.  
  369. 
  370. File: xemacs.info,  Node: Fixing Case,  Next: Spelling,  Prev: Transpose,  Up: Fixit
  371.  
  372. Case Conversion
  373. ===============
  374.  
  375. `M-- M-l'
  376.      Convert last word to lower case.  Note that `Meta--' is
  377.      "Meta-minus."
  378.  
  379. `M-- M-u'
  380.      Convert last word to all upper case.
  381.  
  382. `M-- M-c'
  383.      Convert last word to lower case with capital initial.
  384.  
  385.    A  common error is to type words in the wrong case.  Because of this,
  386. the word case-conversion commands `M-l', `M-u', and `M-c' do not move
  387. the cursor when used with a negative argument.  As soon as you see you
  388. have mistyped the last word, you can simply case-convert it and
  389. continue typing.  *Note Case::.
  390.  
  391. 
  392. File: xemacs.info,  Node: Spelling,  Prev: Fixing Case,  Up: Fixit
  393.  
  394. Checking and Correcting Spelling
  395. ================================
  396.  
  397. `M-$'
  398.      Check and correct spelling of word (`spell-word').
  399.  
  400. `M-x spell-buffer'
  401.      Check and correct spelling of each word in the buffer.
  402.  
  403. `M-x spell-region'
  404.      Check and correct spelling of each word in the region.
  405.  
  406. `M-x spell-string'
  407.      Check spelling of specified word.
  408.  
  409.    To check the spelling of the word before point, and optionally
  410. correct it, use the command `M-$' (`spell-word').  This command runs an
  411. inferior process containing the `spell' program to see whether the word
  412. is correct English.  If it is not, it asks you to edit the word (in the
  413. minibuffer) into a corrected spelling, and then performs a
  414. `query-replace' to substitute the corrected spelling for the old one
  415. throughout the buffer.
  416.  
  417.    If you exit the minibuffer without altering the original spelling, it
  418. means you do not want to do anything to that word.  In that case, the
  419. `query-replace' is not done.
  420.  
  421.    `M-x spell-buffer' checks each word in the buffer the same way that
  422. `spell-word' does, doing a `query-replace' for every incorrect word if
  423. appropriate.
  424.  
  425.    `M-x spell-region' is similar to `spell-buffer' but operates only on
  426. the region, not the entire buffer.
  427.  
  428.    `M-x spell-string' reads a string as an argument and checks whether
  429. that is a correctly spelled English word.  It prints a message giving
  430. the answer in the echo area.
  431.  
  432. 
  433. File: xemacs.info,  Node: Files,  Next: Buffers,  Prev: Fixit,  Up: Top
  434.  
  435. File Handling
  436. *************
  437.  
  438.    The basic unit of stored data in Unix is the "file".  To edit a file,
  439. you must tell Emacs to examine the file and prepare a buffer containing
  440. a copy of the file's text.  This is called "visiting" the file.  Editing
  441. commands apply directly to text in the buffer; that is, to the copy
  442. inside Emacs.  Your changes appear in the file itself only when you
  443. "save" the buffer back into the file.
  444.  
  445.    In addition to visiting and saving files, Emacs can delete, copy,
  446. rename, and append to files, and operate on file directories.
  447.  
  448. * Menu:
  449.  
  450. * File Names::       How to type and edit file name arguments.
  451. * Visiting::         Visiting a file prepares Emacs to edit the file.
  452. * Saving::           Saving makes your changes permanent.
  453. * Reverting::        Reverting cancels all the changes not saved.
  454. * Auto Save::        Auto Save periodically protects against loss of data.
  455. * Version Control::  Version control systems (RCS and SCCS).
  456. * ListDir::          Listing the contents of a file directory.
  457. * Comparing Files::  Finding where two files differ.
  458. * Dired::            "Editing" a directory to delete, rename, etc.
  459.                      the files in it.
  460. * Misc File Ops::    Other things you can do on files.
  461.  
  462. 
  463. File: xemacs.info,  Node: File Names,  Next: Visiting,  Prev: Files,  Up: Files
  464.  
  465. File Names
  466. ==========
  467.  
  468.    Most Emacs commands that operate on a file require you to specify the
  469. file name.  (Saving and reverting are exceptions; the buffer knows which
  470. file name to use for them.)  File names are specified in the minibuffer
  471. (*note Minibuffer::.).  "Completion" is available, to make it easier to
  472. specify long file names.  *Note Completion::.
  473.  
  474.    There is always a "default file name" which is used if you enter an
  475. empty argument by typing just RET.  Normally the default file name is
  476. the name of the file visited in the current buffer; this makes it easy
  477. to operate on that file with any of the Emacs file commands.
  478.  
  479.    Each buffer has a default directory, normally the same as the
  480. directory of the file visited in that buffer.  When Emacs reads a file
  481. name, the default directory is used if you do not specify a directory.
  482. If you specify a directory in a relative fashion, with a name that does
  483. not start with a slash, it is interpreted with respect to the default
  484. directory.  The default directory of the current buffer is kept in the
  485. variable `default-directory', which has a separate value in every
  486. buffer.  The value of the variable should end with a slash.
  487.  
  488.    For example, if the default file name is `/u/rms/gnu/gnu.tasks' then
  489. the default directory is `/u/rms/gnu/'.  If you type just `foo', which
  490. does not specify a directory, it is short for `/u/rms/gnu/foo'.
  491. `../.login' would stand for `/u/rms/.login'.  `new/foo' would stand for
  492. the filename `/u/rms/gnu/new/foo'.
  493.  
  494.    The variable `default-directory-alist' takes an alist of major modes
  495. and their opinions on `default-directory' as a Lisp expression to
  496. evaluate.  A resulting value of `nil' is ignored in favor of
  497. `default-directory'.
  498.  
  499.    You can create a new directory with the function `make-directory',
  500. which takes as an argument a file name string. The current directory is
  501. displayed in the minibuffer when the function is called; you can delete
  502. the old directory name and supply a new directory name. For example, if
  503. the current directory is `/u/rms/gnu', you can delete `gnu' and type
  504. `oryx' and RET to create `/u/rms/oryx'.  Removing a directory is
  505. similar to creating one.  To remove a directory, use
  506. `remove-directory'; it takes one argument, a file name string.
  507.  
  508.    The command `M-x pwd' prints the current buffer's default directory,
  509. and the command `M-x cd' sets it (to a value read using the
  510. minibuffer).  A buffer's default directory changes only when the `cd'
  511. command is used.  A file-visiting buffer's default directory is
  512. initialized to the directory of the file that is visited there.  If a
  513. buffer is created with `C-x b', its default directory is copied from
  514. that of the buffer that was current at the time.
  515.  
  516.    The default directory name actually appears in the minibuffer when
  517. the minibuffer becomes active to read a file name.  This serves two
  518. purposes: it shows you what the default is, so that you can type a
  519. relative file name and know with certainty what it will mean, and it
  520. allows you to edit the default to specify a different directory.  To
  521. inhibit the insertion of the default directory, set the variable
  522. `insert-default-directory' to `nil'.
  523.  
  524.    Note that it is legitimate to type an absolute file name after you
  525. enter the minibuffer, ignoring the presence of the default directory
  526. name.  The final minibuffer contents may look invalid, but that is not
  527. so.  *Note Minibuffer File::.
  528.  
  529.    `$' in a file name is used to substitute environment variables.  For
  530. example, if you have used the shell command `setenv FOO rms/hacks' to
  531. set up an environment variable named `FOO', then you can use
  532. `/u/$FOO/test.c' or `/u/${FOO}/test.c' as an abbreviation for
  533. `/u/rms/hacks/test.c'.  The environment variable name consists of all
  534. the alphanumeric characters after the `$'; alternatively, it may be
  535. enclosed in braces after the `$'.  Note that the `setenv' command
  536. affects Emacs only if done before Emacs is started.
  537.  
  538.    To access a file with `$' in its name, type `$$'.  This pair is
  539. converted to a single `$' at the same time variable substitution is
  540. performed for single `$'.  The Lisp function that performs the
  541. substitution is called `substitute-in-file-name'.  The substitution is
  542. performed only on filenames read as such using the minibuffer.
  543.  
  544. 
  545. File: xemacs.info,  Node: Visiting,  Next: Saving,  Prev: File Names,  Up: Files
  546.  
  547. Visiting Files
  548. ==============
  549.  
  550. `C-x C-f'
  551.      Visit a file (`find-file').
  552.  
  553. `C-x C-v'
  554.      Visit a different file instead of the one visited last
  555.      (`find-alternate-file').
  556.  
  557. `C-x 4 C-f'
  558.      Visit a file, in another window (`find-file-other-window').  Don't
  559.      change this window.
  560.  
  561. `C-x 5 C-f'
  562.      Visit a file, in another frame (`find-file-other-frame').  Don't
  563.      change this window or frame.
  564.  
  565.    "Visiting" a file means copying its contents into an Emacs buffer so
  566. you can edit it.  Emacs creates a new buffer for each file you visit.
  567. We say that the buffer is visiting the file that it was created to
  568. hold.  Emacs constructs the buffer name from the file name by throwing
  569. away the directory and keeping just the file name.  For example, a file
  570. named `/usr/rms/emacs.tex' is displayed in a buffer named `emacs.tex'.
  571. If a buffer with that name exists, a unique name is constructed by
  572. appending `<2>', `<3>',and so on, using the lowest number that makes a
  573. name that is not already in use.
  574.  
  575.    Each window's mode line shows the name of the buffer that is being
  576. displayed in that window, so you can always tell what buffer you are
  577. editing.
  578.  
  579.    The changes you make with Emacs are made in the Emacs buffer.  They
  580. do not take effect in the file that you visit, or any other permanent
  581. place, until you "save" the buffer.  Saving the buffer means that Emacs
  582. writes the current contents of the buffer into its visited file.  *Note
  583. Saving::.
  584.  
  585.    If a buffer contains changes that have not been saved, the buffer is
  586. said to be "modified".  This is important because it implies that some
  587. changes will be lost if the buffer is not saved.  The mode line displays
  588. two stars near the left margin if the buffer is modified.
  589.  
  590.    To visit a file, use the command `C-x C-f' (`find-file').  Follow
  591. the command with the name of the file you wish to visit, terminated by a
  592. RET.  If you are using XEmacs under X, you can also use the Open...
  593. command from the File menu bar item.
  594.  
  595.    The file name is read using the minibuffer (*note Minibuffer::.),
  596. with defaulting and completion in the standard manner (*note File
  597. Names::.).  While in the minibuffer, you can abort `C-x C-f' by typing
  598. `C-g'.
  599.  
  600.    `C-x C-f' has completed successfully when text appears on the screen
  601. and a new buffer name appears in the mode line.  If the specified file
  602. does not exist and could not be created or cannot be read, an error
  603. results.  The error message is printed in the echo area, and includes
  604. the name of the file that Emacs was trying to visit.
  605.  
  606.    If you visit a file that is already in Emacs, `C-x C-f' does not make
  607. another copy.  It selects the existing buffer containing that file.
  608. However, before doing so, it checks that the file itself has not changed
  609. since you visited or saved it last.  If the file has changed, Emacs
  610. prints a warning message.  *Note Simultaneous Editing: Interlocking.
  611.  
  612.    You can switch to a specific file called out in the current buffer by
  613. calling the function `find-this-file'. By providing a prefix argument,
  614. this function calls `filename-at-point' and switches to a buffer
  615. visiting the file FILENAME. It creates one if none already exists. You
  616. can use this function to edit the file mentioned in the buffer you are
  617. working in or to test if the file exists. You can do that by using the
  618. minibuffer completion after snatching the all or part of the filename.
  619.  
  620.    If the variable `find-file-use-truenames''s value is non-`nil', a
  621. buffer's visited filename will always be traced back to the real file.
  622. The filename will never be a symbolic link, and there will never be a
  623. symbolic link anywhere in its directory path. In other words, the
  624. `buffer-file-name' and `buffer-file-truename' will be equal.
  625.  
  626.    If the variable `find-file-compare-truenames' value is non-`nil',
  627. the `find-file' command will check the `buffer-file-truename' of all
  628. visited files when deciding whether a given file is already in a
  629. buffer, instead of just `buffer-file-name'.  If you attempt to visit
  630. another file which is a hard-link or symbolic-link to a file that is
  631. already in a buffer, the existing buffer will be found instead of a
  632. newly created one.
  633.  
  634.    If you want to create a file, just visit it.  Emacs prints `(New
  635. File)' in the echo area, but in other respects behaves as if you had
  636. visited an existing empty file.  If you make any changes and save them,
  637. the file is created.
  638.  
  639.    If you visit a nonexistent file unintentionally (because you typed
  640. the wrong file name), use the `C-x C-v' (`find-alternate-file') command
  641. to visit the file you wanted.  `C-x C-v' is similar to `C-x C-f', but
  642. it kills the current buffer (after first offering to save it if it is
  643. modified).  `C-x C-v' is allowed even if the current buffer is not
  644. visiting a file.
  645.  
  646.    If the file you specify is actually a directory, Dired is called on
  647. that directory (*note Dired::.).  To inhibit this, set the variable
  648. `find-file-run-dired' to `nil'; then it is an error to try to visit a
  649. directory.
  650.  
  651.    `C-x 4 f' (`find-file-other-window') is like `C-x C-f' except that
  652. the buffer containing the specified file is selected in another window.
  653. The window that was selected before `C-x 4 f' continues to show the
  654. same buffer it was already showing.  If you use this command when only
  655. one window is being displayed, that window is split in two, with one
  656. window showing the same buffer as before, and the other one showing the
  657. newly requested file.  *Note Windows::.
  658.  
  659.    `C-x 5 C-f' (`find-file-other-frame') is like `C-x C-f' except that
  660. it creates a new frame in which the file is displayed.
  661.  
  662.    Use the function `find-this-file-other-window' to edit a file
  663. mentioned in the buffer you are editing or to test if that file exists.
  664. To do do this, use the minibuffer completion after snatching the part or
  665. all of the filename. By providing a prefix argument, the function calls
  666. `filename-at-point' and switches you to a buffer visiting the file
  667. FILENAME in another window. The function creates a buffer if none
  668. already exists. This function is similar to `find-file-other-window'.
  669.  
  670.    There are two hook variables that allow extensions to modify the
  671. operation of visiting files.  Visiting a file that does not exist runs
  672. the functions in the list `find-file-not-found-hooks'; the value of this
  673. variable is expected to be a list of functions which are called one by
  674. one until one of them returns non-`nil'.  Any visiting of a file,
  675. whether extant or not, expects `find-file-hooks' to contain list of
  676. functions and calls them all, one by one.  In both cases the functions
  677. receive no arguments.  Visiting a nonexistent file runs the
  678. `find-file-not-found-hooks' first.
  679.  
  680. 
  681. File: xemacs.info,  Node: Saving,  Next: Reverting,  Prev: Visiting,  Up: Files
  682.  
  683. Saving Files
  684. ============
  685.  
  686.    "Saving" a buffer in Emacs means writing its contents back into the
  687. file that was visited in the buffer.
  688.  
  689. `C-x C-s'
  690.      Save the current buffer in its visited file (`save-buffer').
  691.  
  692. `C-x s'
  693.      Save any or all buffers in their visited files
  694.      (`save-some-buffers').
  695.  
  696. `M-~'
  697.      Forget that the current buffer has been changed (`not-modified').
  698.  
  699. `C-x C-w'
  700.      Save the current buffer in a specified file, and record that file
  701.      as the one visited in the buffer (`write-file').
  702.  
  703. `M-x set-visited-file-name'
  704.      Change file the name under which the current buffer will be saved.
  705.  
  706.    To save a file and make your changes permanent, type `C-x C-s'
  707. (`save-buffer').  After saving is finished, `C-x C-s' prints a message
  708. such as:
  709.  
  710.      Wrote /u/rms/gnu/gnu.tasks
  711.  
  712. If the selected buffer is not modified (no changes have been made in it
  713. since the buffer was created or last saved), Emacs does not save it
  714. because it would have no effect.  Instead, `C-x C-s' prints a message
  715. in the echo area saying:
  716.  
  717.      (No changes need to be saved)
  718.  
  719.    The command `C-x s' (`save-some-buffers') can save any or all
  720. modified buffers.  First it asks, for each modified buffer, whether to
  721. save it.  The questions should be answered with `y' or `n'.  `C-x C-c',
  722. the key that kills Emacs, invokes `save-some-buffers' and therefore
  723. asks the same questions.
  724.  
  725.    If you have changed a buffer and do not want the changes to be saved,
  726. you should take some action to prevent it.  Otherwise, you are liable to
  727. save it by mistake each time you use `save-some-buffers' or a related
  728. command.  One thing you can do is type `M-~' (`not-modified'), which
  729. removes the indication that the buffer is modified.  If you do this,
  730. none of the save commands will believe that the buffer needs to be
  731. saved.  (`~' is often used as a mathematical symbol for `not'; thus
  732. `Meta-~' is `not', metafied.) You could also use
  733. `set-visited-file-name' (see below) to mark the buffer as visiting a
  734. different file name, not in use for anything important.
  735.  
  736.    You can also undo all the changes made since the file was visited or
  737. saved, by reading the text from the file again.  This is called
  738. "reverting".  *Note Reverting::.  Alternatively, you can undo all the
  739. changes by repeating the undo command `C-x u'; but this only works if
  740. you have not made more changes than the undo mechanism can remember.
  741.  
  742.    `M-x set-visited-file-name' alters the name of the file that the
  743. current buffer is visiting.  It prompts you for the new file name in the
  744. minibuffer.  You can also use `set-visited-file-name' on a buffer that
  745. is not visiting a file.  The buffer's name is changed to correspond to
  746. the file it is now visiting unless the new name is already used by a
  747. different buffer; in that case, the buffer name is not changed.
  748. `set-visited-file-name' does not save the buffer in the newly visited
  749. file; it just alters the records inside Emacs so that it will save the
  750. buffer in that file.  It also marks the buffer as "modified" so that
  751. `C-x C-s' will save.
  752.  
  753.    If you wish to mark a buffer as visiting a different file and save it
  754. right away, use `C-x C-w' (`write-file').  It is precisely equivalent
  755. to `set-visited-file-name' followed by `C-x C-s'.  `C-x C-s' used on a
  756. buffer that is not visiting  a file has the same effect as `C-x C-w';
  757. that is, it reads a file name, marks the buffer as visiting that file,
  758. and saves it there.  The default file name in a buffer that is not
  759. visiting a file is made by combining the buffer name with the buffer's
  760. default directory.
  761.  
  762.    If Emacs is about to save a file and sees that the date of the latest
  763. version on disk does not match what Emacs last read or wrote, Emacs
  764. notifies you of this fact, because it probably indicates a problem
  765. caused by simultaneous editing and requires your immediate attention.
  766. *Note Simultaneous Editing: Interlocking.
  767.  
  768.    If the variable `require-final-newline' is non-`nil', Emacs puts a
  769. newline at the end of any file that doesn't already end in one, every
  770. time a file is saved or written.
  771.  
  772.    Use the hook variable `write-file-hooks' to implement other ways to
  773. write files, and specify things to be done before files are written.
  774. The value of this variable should be a list of Lisp functions.  When a
  775. file is to be written, the functions in the list are called, one by
  776. one, with no arguments.  If one of them returns a non-`nil' value, Emacs
  777. takes this to mean that the file has been written in some suitable
  778. fashion; the rest of the functions are not called, and normal writing is
  779. not done. Use the hook variable `after-save-hook' to list all the
  780. functions to be called after writing out a buffer to a file.
  781.  
  782. * Menu:
  783.  
  784. * Backup::       How Emacs saves the old version of your file.
  785. * Interlocking:: How Emacs protects against simultaneous editing
  786.                   of one file by two users.
  787.  
  788. 
  789. File: xemacs.info,  Node: Backup,  Next: Interlocking,  Prev: Saving,  Up: Saving
  790.  
  791. Backup Files
  792. ------------
  793.  
  794.    Because Unix does not provide version numbers in file names,
  795. rewriting a file in Unix automatically destroys all record of what the
  796. file used to contain.  Thus, saving a file from Emacs throws away the
  797. old contents of the file--or it would, except that Emacs carefully
  798. copies the old contents to another file, called the "backup" file,
  799. before actually saving.  (Make sure that the variable
  800. `make-backup-files' is non-`nil'.  Backup files are not written if this
  801. variable is `nil').
  802.  
  803.    At your option, Emacs can keep either a single backup file or a
  804. series of numbered backup files for each file you edit.
  805.  
  806.    Emacs makes a backup for a file only the first time a file is saved
  807. from one buffer.  No matter how many times you save a file, its backup
  808. file continues to contain the contents from before the file was visited.
  809. Normally this means that the backup file contains the contents from
  810. before the current editing session; however, if you kill the buffer and
  811. then visit the file again, a new backup file is made by the next save.
  812.  
  813. * Menu:
  814.  
  815. * Names: Backup Names.        How backup files are named;
  816.                 Choosing single or numbered backup files.
  817. * Deletion: Backup Deletion.    Emacs deletes excess numbered backups.
  818. * Copying: Backup Copying.    Backups can be made by copying or renaming.
  819.  
  820. 
  821. File: xemacs.info,  Node: Backup Names,  Next: Backup Deletion,  Prev: Backup,  Up: Backup
  822.  
  823. Single or Numbered Backups
  824. ..........................
  825.  
  826.    If you choose to have a single backup file (the default), the backup
  827. file's name is constructed by appending `~' to the file name being
  828. edited; thus, the backup file for `eval.c' is `eval.c~'.
  829.  
  830.    If you choose to have a series of numbered backup files, backup file
  831. names are made by appending `.~', the number, and another `~' to the
  832. original file name.  Thus, the backup files of `eval.c' would be called
  833. `eval.c.~1~', `eval.c.~2~', and so on, through names like
  834. `eval.c.~259~' and beyond.
  835.  
  836.    If protection stops you from writing backup files under the usual
  837. names, the backup file is written as `%backup%~' in your home directory.
  838. Only one such file can exist, so only the most recently made backup is
  839. available.
  840.  
  841.    The choice of single backup or numbered backups is controlled by the
  842. variable `version-control'.  Its possible values are:
  843.  
  844. `t'
  845.      Make numbered backups.
  846.  
  847. `nil'
  848.      Make numbered backups for files that have numbered backups already.
  849.      Otherwise, make single backups.
  850.  
  851. `never'
  852.      Never make numbered backups; always make single backups.
  853.  
  854. `version-control' may be set locally in an individual buffer to control
  855. the making of backups for that buffer's file.  For example, Rmail mode
  856. locally sets `version-control' to `never' to make sure that there is
  857. only one backup for an Rmail file.  *Note Locals::.
  858.  
  859. 
  860. File: xemacs.info,  Node: Backup Deletion,  Next: Backup Copying,  Prev: Backup Names,  Up: Backup
  861.  
  862. Automatic Deletion of Backups
  863. .............................
  864.  
  865.    To prevent unlimited consumption of disk space, Emacs can delete
  866. numbered backup versions automatically.  Generally Emacs keeps the
  867. first few backups and the latest few backups, deleting any in between.
  868. This happens every time a new backup is made.  The two variables that
  869. control the deletion are `kept-old-versions' and `kept-new-versions'.
  870. Their values are, respectively the number of oldest (lowest-numbered)
  871. backups to keep and the number of newest (highest-numbered) ones to
  872. keep, each time a new backup is made.  The values are used just after a
  873. new backup version is made; that newly made backup is included in the
  874. count in `kept-new-versions'.  By default, both variables are 2.
  875.  
  876.    If `trim-versions-without-asking' is non-`nil',  excess middle
  877. versions are deleted without notification.  If it is `nil', the
  878. default, you are asked whether the excess middle versions should really
  879. be deleted.
  880.  
  881.    You can also use Dired's `.' (Period) command to delete old versions.
  882. *Note Dired::.
  883.  
  884. 
  885. File: xemacs.info,  Node: Backup Copying,  Prev: Backup Deletion,  Up: Backup
  886.  
  887. Copying vs. Renaming
  888. ....................
  889.  
  890.    You can make backup files by copying the old file or by renaming it.
  891. This makes a difference when the old file has multiple names.  If you
  892. rename the old file into the backup file, the alternate names become
  893. names for the backup file.  If you copy the old file instead, the
  894. alternate names remain names for the file that you are editing, and the
  895. contents accessed by those names will be the new contents.
  896.  
  897.    How you make a backup file may also affect the file's owner and
  898. group.  If you use copying, they do not change.  If renaming is used,
  899. you become the file's owner, and the file's group becomes the default
  900. (different operating systems have different defaults for the group).
  901.  
  902.    Having the owner change is usually a good idea, because then the
  903. owner is always the person who last edited the file.  Occasionally
  904. there is a file whose owner should not change.  Since most files should
  905. change owners, it is a good idea to use local variable lists to set
  906. `backup-by-copying-when-mismatch' for the special cases where the owner
  907. should not change (*note File Variables::.).
  908.  
  909.    Three variables control the choice of renaming or copying.
  910. Normally, renaming is done.  If the variable `backup-by-copying' is
  911. non-`nil', copying is used.  Otherwise, if the variable
  912. `backup-by-copying-when-linked' is non-`nil', copying is done for files
  913. that have multiple names, but renaming may still be done when the file
  914. being edited has only one name.  If the variable
  915. `backup-by-copying-when-mismatch' is non-`nil', copying is done if
  916. renaming would cause the file's owner or group to change.
  917.  
  918. 
  919. File: xemacs.info,  Node: Interlocking,  Prev: Backup,  Up: Saving
  920.  
  921. Protection Against Simultaneous Editing
  922. ---------------------------------------
  923.  
  924.    Simultaneous editing occurs when two users visit the same file, both
  925. make changes, and both save their changes.  If no one was informed that
  926. this was happening, and you saved first, you would later find that your
  927. changes were lost.  On some systems, Emacs notices immediately when the
  928. second user starts to change a file already being edited, and issues a
  929. warning.  When this is not possible, or if the second user has started
  930. to change the file despite the warning, Emacs checks when the file is
  931. saved, and issues a second warning when a user is about to overwrite a
  932. file containing another user's changes.  If you are the user editing the
  933. file, you can take corrective action at this point and prevent actual
  934. loss of work.
  935.  
  936.    When you make the first modification in an Emacs buffer that is
  937. visiting a file, Emacs records that you have locked the file.  (It does
  938. this by writing another file in a directory reserved for this purpose.)
  939. The lock is removed when you save the changes.  The idea is that the
  940. file is locked whenever the buffer is modified.  If you begin to modify
  941. the buffer while the visited file is locked by someone else, this
  942. constitutes a collision, and Emacs asks you what to do.  It does this
  943. by calling the Lisp function `ask-user-about-lock', which you can
  944. redefine to customize what it does.  The standard definition of this
  945. function asks you a question and accepts three possible answers:
  946.  
  947. `s'
  948.      Steal the lock.  Whoever was already changing the file loses the
  949.      lock, and you get the lock.
  950.  
  951. `p'
  952.      Proceed.  Go ahead and edit the file despite its being locked by
  953.      someone else.
  954.  
  955. `q'
  956.      Quit.  This causes an error (`file-locked') and the modification
  957.      you were trying to make in the buffer does not actually take place.
  958.  
  959.    Note that locking works on the basis of a file name; if a file has
  960. multiple names, Emacs does not realize that the two names are the same
  961. file and cannot prevent two users from editing it simultaneously under
  962. different names.  However, basing locking on names means that Emacs can
  963. interlock the editing of new files that do not really exist until they
  964. are saved.
  965.  
  966.    Some systems are not configured to allow Emacs to make locks.  On
  967. these systems, Emacs cannot detect trouble in advance, but it can still
  968. detect it in time to prevent you from overwriting someone else's
  969. changes.
  970.  
  971.    Every time Emacs saves a buffer, it first checks the
  972. last-modification date of the existing file on disk to see that it has
  973. not changed since the file was last visited or saved.  If the date does
  974. not match, it implies that changes were made in the file in some other
  975. way, and these changes are about to be lost if Emacs actually does
  976. save.  To prevent this, Emacs prints a warning message and asks for
  977. confirmation before saving.  Occasionally you will know why the file
  978. was changed and know that it does not matter; then you can answer `yes'
  979. and proceed.  Otherwise, you should cancel the save with `C-g' and
  980. investigate the situation.
  981.  
  982.    The first thing you should do when notified that simultaneous editing
  983. has already taken place is to list the directory with `C-u C-x C-d'
  984. (*note Directory Listing: ListDir.).  This will show the file's current
  985. author.  You should attempt to contact that person and ask him not to
  986. continue editing.  Often the next step is to save the contents of your
  987. Emacs buffer under a different name, and use `diff' to compare the two
  988. files.
  989.  
  990.    Simultaneous editing checks are also made when you visit a file that
  991. is already visited with `C-x C-f' and when you start to modify a file.
  992. This is not strictly necessary, but it is useful to find out about such
  993. a problem as early as possible, when corrective action takes less work.
  994.  
  995.    Another way to protect your file is to set the read, write, and
  996. executable permissions for the file. Use the function
  997. `set-default-file-modes' to set the UNIX `umask' value to the NMASK
  998. argument. The `umask' value is the default protection mode for new
  999. files.
  1000.  
  1001. 
  1002. File: xemacs.info,  Node: Reverting,  Next: Auto Save,  Prev: Saving,  Up: Files
  1003.  
  1004. Reverting a Buffer
  1005. ==================
  1006.  
  1007.    If you have made extensive changes to a file and then change your
  1008. mind about them, you can get rid of all changes by reading in the
  1009. previous version of the file.  To do this, use `M-x revert-buffer',
  1010. which operates on the current buffer.  Since reverting a buffer can
  1011. result in very extensive changes, you must confirm it with `yes'.
  1012.  
  1013.    If the current buffer has been auto-saved more recently than it has
  1014. been saved explicitly, `revert-buffer' offers to read the auto save file
  1015. instead of the visited file (*note Auto Save::.).  Emacs asks you about
  1016. the auto-save file before the request for confirmation of the
  1017. `revert-buffer' operation, and demands `y' or `n' as an answer.  If you
  1018. have started to type `yes' for confirmation without realizing that the
  1019. auto-save question was going to be asked, the `y' will answer that
  1020. question, but the `es' will not be valid confirmation.  This gives you
  1021. a chance to cancel the operation with `C-g' and try again with the
  1022. answers you really intend.
  1023.  
  1024.    `revert-buffer' keeps point at the same distance (measured in
  1025. characters) from the beginning of the file.  If the file was edited only
  1026. slightly, you will be at approximately the same piece of text after
  1027. reverting as before.  If you have made more extensive changes, the
  1028. value of point in the old file may bring you to a totally different
  1029. piece of text than your last editing point.
  1030.  
  1031.    A buffer reverted from its visited file is marked "not modified"
  1032. until you make a change.
  1033.  
  1034.    Some kinds of buffers whose contents reflect data bases other than
  1035. files, such as Dired buffers, can also be reverted.  For them,
  1036. reverting means recalculating their contents from the appropriate data.
  1037. Buffers created randomly with `C-x b' cannot be reverted;
  1038. `revert-buffer' reports an error when asked to do so.
  1039.  
  1040. 
  1041. File: xemacs.info,  Node: Auto Save,  Next: Version Control,  Prev: Reverting,  Up: Files
  1042.  
  1043. Auto-Saving: Protection Against Disasters
  1044. =========================================
  1045.  
  1046.    Emacs saves all the visited files from time to time (based on
  1047. counting your keystrokes) without being asked.  This is called
  1048. "auto-saving".  It prevents you from losing more than a limited amount
  1049. of work if the system crashes.
  1050.  
  1051.    When Emacs determines it is time for auto-saving, each buffer is
  1052. considered and is auto-saved if auto-saving is turned on for it and it
  1053. has changed since the last time it was auto-saved.  If any auto-saving
  1054. is done, the message `Auto-saving...' is displayed in the echo area
  1055. until auto-saving is finished.  Errors occurring during auto-saving are
  1056. caught so that they do not interfere with the execution of commands you
  1057. have been typing.
  1058.  
  1059. * Menu:
  1060.  
  1061. * Files: Auto Save Files.
  1062. * Control: Auto Save Control.
  1063. * Recover::        Recovering text from auto-save files.
  1064.  
  1065. 
  1066. File: xemacs.info,  Node: Auto Save Files,  Next: Auto Save Control,  Prev: Auto Save,  Up: Auto Save
  1067.  
  1068. Auto-Save Files
  1069. ---------------
  1070.  
  1071.    Auto-saving does not normally write to the files you visited, because
  1072. it can be undesirable to save a program that is in an inconsistent
  1073. state when you have made only half of a planned change.  Instead,
  1074. auto-saving is done in a different file called the "auto-save file",
  1075. and the visited file is changed only when you save explicitly, for
  1076. example, with `C-x C-s'.
  1077.  
  1078.    Normally, the name of the auto-save file is generated by appending
  1079. `#' to the front and back of the visited file name.  Thus, a buffer
  1080. visiting file `foo.c' would be auto-saved in a file `#foo.c#'.  Most
  1081. buffers that are not visiting files are auto-saved only if you request
  1082. it explicitly; when they are auto-saved, the auto-save file name is
  1083. generated by appending `#%' to the front and `#' to the back of buffer
  1084. name.  For example, the `*mail*' buffer in which you compose messages
  1085. to be sent is auto-saved in a file named `#%*mail*#'.  Names of
  1086. auto-save files are generated this way unless you customize the
  1087. functions `make-auto-save-file-name' and `auto-save-file-name-p' to do
  1088. something different.  The file name to be used for auto-saving a buffer
  1089. is calculated at the time auto-saving is turned on in that buffer.
  1090.  
  1091.    If you want auto-saving to be done in the visited file, set the
  1092. variable `auto-save-visited-file-name' to be non-`nil'.  In this mode,
  1093. there is really no difference between auto-saving and explicit saving.
  1094.  
  1095.    Emacs deletes a buffer's auto-save file when you explicitly save the
  1096. buffer.  To inhibit the deletion, set the variable
  1097. `delete-auto-save-files' to `nil'.  Changing the visited file name with
  1098. `C-x C-w' or `set-visited-file-name' renames any auto-save file to
  1099. correspond to the new visited name.
  1100.  
  1101. 
  1102. File: xemacs.info,  Node: Auto Save Control,  Next: Recover,  Prev: Auto Save Files,  Up: Auto Save
  1103.  
  1104. Controlling Auto-Saving
  1105. -----------------------
  1106.  
  1107.    Each time you visit a file, auto-saving is turned on for that file's
  1108. buffer if the variable `auto-save-default' is non-`nil' (but not in
  1109. batch mode; *note Entering Emacs::.).  The default for this variable is
  1110. `t', so Emacs auto-saves buffers that visit files by default.  You can
  1111. use the command `M-x auto-save-mode' to turn auto-saving for a buffer
  1112. on or off.  Like other minor mode commands, `M-x auto-save-mode' turns
  1113. auto-saving on with a positive argument, off with a zero or negative
  1114. argument; with no argument, it toggles.
  1115.  
  1116.    Emacs performs auto-saving periodically based on counting how many
  1117. characters you have typed since the last time auto-saving happened.  The
  1118. variable `auto-save-interval' specifies the number of characters
  1119. between auto-saves.  By default, it is 300.  Emacs also auto-saves
  1120. whenever you call the function `do-auto-save'.
  1121.  
  1122.    Emacs also does auto-saving whenever it gets a fatal error.  This
  1123. includes killing the Emacs job with a shell command such as `kill
  1124. -emacs', or disconnecting a phone line or network connection.
  1125.  
  1126.    You can set the number of seconds of idle time before an auto-save is
  1127. done. Setting the value of the variable `auto-save-timeout' to zero or
  1128. `nil' will  disable auto-saving due to idleness.
  1129.  
  1130.    The actual amount of idle time between auto-saves is logarithmically
  1131. related to the size of the current buffer.  This variable is the number
  1132. of seconds after which an auto-save will happen when the current buffer
  1133. is 50k or less; the timeout will be 2 1/4 times this in a 200k buffer, 3
  1134. 3/4 times this in a 1000k buffer, and 4 1/2 times this in a 2000k
  1135. buffer.
  1136.  
  1137.    For this variable to have any effect, you must do `(require 'timer)'.
  1138.  
  1139.